//package com.plian.system.controller.im;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.plian.Tools.*;
//import com.plian.Tools.base.BaseController;
//import com.plian.Tools.pagedata.PageData;
//import com.plian.system.common.status.CustomCode;
//import com.plian.system.config.Resubmit;
//import com.plian.system.entity.im.InvestmentDebtInfo;
//import com.plian.system.model.CommonCode;
//import com.plian.system.model.ListResult;
//import com.plian.system.model.ObjResult;
//import com.plian.system.model.R;
//import com.plian.system.model.token.PassToken;
//import com.plian.system.mybatis.search.SearchEntity;
//import com.plian.system.mybatis.search.SearchParamEntiy;
//import com.plian.system.mybatis.search.TokenSearch;
//import com.plian.system.mybatis.support.Condition;
//import com.plian.system.mybatis.support.Query;
//import com.plian.system.service.im.IInvestmentDebtInfoService;
//import com.plian.system.vo.im.InvestmentDebtInfoVO;
//import com.plian.system.wrapper.im.InvestmentDebtInfoWrapper;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.web.bind.annotation.*;
//import org.springframework.web.multipart.MultipartFile;
//
//import javax.servlet.http.HttpServletResponse;
//import javax.validation.Valid;
//import java.io.IOException;
//import java.io.InputStream;
//import java.io.OutputStream;
//import java.util.List;
//
///**
// * 控制器
// */
//@Slf4j
//@RestController
//@AllArgsConstructor
//@RequestMapping("api/investmentDebtInfo")
//@Api(value = "InvestmentDebtInfoController", tags = "债务余额与结构 控制器")
//public class InvestmentDebtInfoController extends BaseController {
//
//	private IInvestmentDebtInfoService investmentDebtInfoService;
//
//	private InvestmentDebtInfoWrapper investmentDebtInfoWrapper;
//
//	/**
//	 * 详情
//	 */
//	@PostMapping("/detail")
//	@ApiOperation(value = "详情")
//	public R<InvestmentDebtInfoVO> detail(@RequestBody InvestmentDebtInfo investmentDebtInfo) {
//		InvestmentDebtInfo detail = investmentDebtInfoService.getOne(Condition.getQueryWrapper(investmentDebtInfo));
//		InvestmentDebtInfoVO investmentDebtInfoVO = investmentDebtInfoWrapper.entityToVO(detail);
//		return R.data(investmentDebtInfoVO);
//	}
//
//	/**
//	 * 分页
//	 */
//	@PostMapping("/list")
//	@ApiOperation(value = "分页")
//	public ListResult<InvestmentDebtInfoVO> list(@RequestBody Query query) {
//		List<SearchEntity> entityList = query.getSearch();
//		if (query.getAscs()==null&&query.getDescs()==null){
//			query.setDescs("create_time,id");
//		}
//		QueryWrapper<InvestmentDebtInfo> queryWrapper = SearchParamEntiy.getQueryWrapper(
//				Condition.getQueryWrapper(new InvestmentDebtInfo()), entityList
//		);
//		TokenSearch<InvestmentDebtInfo> tokenSearch = new TokenSearch<>();
//		tokenSearch.addTokenQuery(queryWrapper, query);
//		IPage<InvestmentDebtInfo> pages = investmentDebtInfoService.page(Condition.getPage(query), queryWrapper);
//		List<InvestmentDebtInfoVO> investmentDebtInfoVOS = investmentDebtInfoWrapper.entityToVO(pages.getRecords());
//		ListResult<InvestmentDebtInfoVO> listResult = new ListResult<>(CommonCode.SUCCESS);
//		listResult.setList(investmentDebtInfoVOS);
//		listResult.setTotal(Long.valueOf(pages.getTotal()).intValue());
//		return listResult;
//	}
//
//	/**
//	 * 新增或修改
//	 */
//	@PostMapping("/submit")
//	@Resubmit(delaySeconds = 0)
//	@ApiOperation(value = "新增或修改")
//	public R submit(@Valid @RequestBody InvestmentDebtInfo investmentDebtInfo) {
//		String checkMessage = investmentDebtInfoService.checkName(investmentDebtInfo);
//		if (StringUtil.isNotBlank(checkMessage)){
//			return new R(CustomCode.builder().message(checkMessage).code(1999).success(false).build());
//		}
//		return investmentDebtInfoService.saveOrUpdate(investmentDebtInfo)
//				? new R(CommonCode.SUCCESS) : new R(CommonCode.FAIL);
//
//	}
//
//	/**
// 	* 删除
//	 */
//	@PostMapping("/remove")
//	@ApiOperation(value = "删除")
//	public R remove(@RequestBody PageData pd) {
//		List<String> ids = (List<String>)pd.get("ids");
//		return investmentDebtInfoService.deleteLogic(Func.toLongList(StringUtils.join(ids, StringPool.COMMA)))
//				? new R(CommonCode.SUCCESS) : new R(CommonCode.FAIL);
//	}
//
//	@GetMapping("/exportTemplateExcel")
//	@PassToken
//	public void exportTemplateExcel(HttpServletResponse response, OutputStream os){
//		investmentDebtInfoService.exportTemplateExcel(response, os);
//	}
//	/**
//	 * 覆盖导入 根据填报时间 填报单位覆盖或新增
//	 */
//	@PostMapping("/excelCoverImport")
//	@ApiOperation(value = "覆盖导入 根据填报时间 填报单位覆盖或新增")
//	public ObjResult excelCoverImport(@RequestParam("file") MultipartFile multipartFile) throws IOException {
//		String progressId = TokenUtil.getTokenUserId() + "_"+System.currentTimeMillis();
//		CacheUtil.put("progress","progress",progressId + "#half:hour",0);
//		InputStream inputStream = multipartFile.getInputStream();
//		investmentDebtInfoService.importExcel(progressId, inputStream);
//		ObjResult objResult = new ObjResult(CommonCode.SUCCESS);
//		PageData pd = new PageData();
//		pd.put("progressId", progressId);
//		objResult.setPageData(pd);
//		return objResult;
//	}
//
//	/**
//	 * 导入进度查看
//	 */
//	@GetMapping("/progress/{progressId}")
//	@ApiOperation(value = "导入进度查看")
//	public ObjResult progress(@PathVariable String progressId){
//		Object data = CacheUtil.get("progress", "progress", progressId + "#half:hour");
//		if(data != null && data instanceof String){
//			if ("导入成功".equals(data)){
//				ObjResult objResult = new ObjResult(CommonCode.SUCCESS);
//				PageData pd = new PageData();
//				pd.put("data", 200);
//				objResult.setPageData(pd);
//				return objResult;
//			}
//			return new ObjResult(CustomCode.builder().message((String)data).code(1000).success(false).build());
//		}
//		ObjResult objResult = new ObjResult(CommonCode.SUCCESS);
//		PageData pd = new PageData();
//		pd.put("data", data);
//		objResult.setPageData(pd);
//		return objResult;
//	}
//
//}
